<template>
	<view>
		<view>
			<text>{{ random }}</text>
		</view>
	</view>
</template>

<script>
	var self;
	export default {
		 data() {
		  return {
			random: 0,
			timer: null,
      }
		},
		onLoad: function() {
			self = this; //self指向vm的实例
			this.timer = setInterval(function() {
				self.random = Math.random(); //修改对象
			}, 1000);
		},
		onUnload: function() {
			if (this.timer) {
				clearInterval(this.timer); //销毁定时器
			}
		}
	}
</script>

<style>

</style>
